package com.naive.imperative.program;

import com.naive.imperative.view.IterableSparceArray;

public abstract class Operation {
	private final IterableSparceArray<Block> containers = new IterableSparceArray<Block>();
	private final IterableSparceArray<EvaluatableOperation<?>> operations = new IterableSparceArray<EvaluatableOperation<?>>();

	protected void set(EditContext ec, int id, Block oc) {
		containers.put(id, oc);
	}

	protected void set(EditContext ec, int id, EvaluatableOperation<?> oc) {
		assert this == ec.getTarget();
		ec.beforeSet(id, oc);
		operations.put(id, oc);
	}

	public abstract void execute(ExecutionContext x);

	public Iterable<EvaluatableOperation<?>> operations() {
		return operations;
	}

	public Iterable<Block> blocks() {
		return containers;
	}
}
